



# 151.翻转字符串里的单词

def main(s):
    s_list = list(s)
    while True:
        if s_list[0]==' ':
            del s_list[0]
        else:
            break
    while True:
        if s_list[len(s_list)-1]==' ':
            del s_list[len(s_list)-1]
        else:
            break
    s = ''.join(s_list)
    kong = " "
    for i in range(0,100000):
        kong = kong + " "
        s = s.replace(kong,' ')
    result = []
    temp = ''
    for i in range(0,len(s)):
        if s[i]==' ':
            result.append(temp)
            temp = ''
            continue
        temp = temp + s[i]
    result.append(temp)
    print(result)
    results = ''
    for i in range(len(result)-1,-1,-1):
        results = results + result[i]
        if i!=0:
            results = results + ' '
    return results

if __name__ == "__main__":
    s = input()
    results = main(s)
    print(results)